package thread;

public class MyThread3 {
    public static void main(String[] args) throws InterruptedException {
        Thread t = new Thread(()->{
           for (int i = 0; i < 7; i++){
               System.out.println(Thread.currentThread().getState());  // 正在运行 就绪态
               try {
                   Thread.sleep(1000);
               } catch (InterruptedException e) {
                   throw new RuntimeException(e);
               }
           }
        });
        System.out.println(t.getState());  // NEW态
        t.start();
        for (int i = 0; i < 5; i++) {
            System.out.println(t.getState());  //  TIMED_WAITING
            Thread.sleep(800);
        }
        t.join();
        System.out.println(t.getState());  //  TERMINATED态
    }
}
